﻿/*
 *  UI_Frame.h
 *
 *	Date: 2011-4-24
 *  Author: linshenqi
 */
 
#include "./GUI.h"
#include <stdlib.h>
#include <iostream>
#include <wx/dcbuffer.h>

using namespace std;

BEGIN_EVENT_TABLE(MainFrame, wxFrame)
	EVT_MENU(wxID_ABOUT, MainFrame::EvtAbout)
	EVT_MENU(wxID_EXIT, MainFrame::EvtExit)
	//EVT_BUTTON(wxID_OK, MainFrame::EvtAbout)
	EVT_MOTION(MainFrame::OnMotion)
END_EVENT_TABLE()

MainFrame::MainFrame(const wxString& title, const wxSize& size)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, size)
, m_pMenuBar(NULL)
, m_pMenuFile(NULL)
, m_pMenuAbout(NULL)
{
	Init();
}

MainFrame::~MainFrame()
{
}

void MainFrame::OnMotion(wxMouseEvent& event)
{
	if(event.Dragging())
	{
		wxClientDC dc(this);
		wxPen pen(wxColor(0, 0, 0), 8);
		dc.SetPen(pen);
		dc.DrawPoint(event.GetPosition());
		dc.SetPen(wxNullPen);
	}
}

void MainFrame::Init()
{
	if(!m_pMenuBar)
		m_pMenuBar = new wxMenuBar;
		
	if(!m_pMenuFile)
		m_pMenuFile = new wxMenu;
		
	if(!m_pMenuAbout)
		m_pMenuAbout = new wxMenu;
	
	m_pMenuFile->Append(wxID_EXIT, wxT("退出"), wxT("退出"));
	m_pMenuAbout->Append(wxID_ABOUT, wxT("关于"), wxT("关于"));
	
	m_pMenuBar->Append(m_pMenuFile, wxT("文件"));
	m_pMenuBar->Append(m_pMenuAbout, wxT("关于"));
	
	this->SetMenuBar(m_pMenuBar);
	
	m_pPnl = new GUI_Panel(this);
}

void MainFrame::EvtExit(wxCommandEvent& event)
{
	this->Close();
}

void MainFrame::EvtAbout(wxCommandEvent& event)
{
	wxString str;
	str.Printf(wxT("%s"), wxVERSION_STRING);
	int x,y;
	this->GetClientSize(&x, &y);
	wxMessageBox(str, wxT("关于"), wxOK | wxICON_INFORMATION, this);
	str.Printf(wxT("%d  %d"), x, y);
	wxMessageBox(str, wxT("关于"), wxOK | wxICON_INFORMATION, this);
}
